--File ： ChapterView.lua
--Author : zee
--Date   : 2015/4/8
--Description : 关卡主界面 chapter.fla 第一帧



CrashGroup = class("CrashGroup",function()
    -- 继承
    local ret = {} 

    ret.ary_obj = {}
    
    ret.n_crashId = 0

    ret.n_objCount = 0

    ret.ary_carshId = {}

    return ret
end)



CrashCenter = class("CrashCenter",function()
    -- 继承
    local ret = {} 

    ret.ary_crashAry = {}
    
    return ret
end)

CrashCenter.__index = CrashCenter
CrashCenter.__instance = nil



--------------------------------------------------------
-- 初始化
--------------------------------------------------------
function CrashCenter:create()
    CrashCenter.__instance = CrashCenter:new()
    CrashCenter.__instance:init()
end 


function CrashCenter:init()
    self.ary_crashAry = {}
end





--------------------------------------------------------
-- 添加碰撞对象
--------------------------------------------------------
function CrashCenter:addCrashObj(node, id, size)
    if (self.ary_crashAry[id]==nil) then
        local cg = CrashGroup:new()
        cg:addCrashObj(node, id, size)
        self.ary_crashAry[id] = cg
    else
        local cg = self.ary_crashAry[id]
        cg:addCrashObj(node, id, size)
    end
end





function CrashCenter:onFrame(dt)
    -- 之后添加碰撞检查的代码。
end





--------------------------------------------------------
-- 添加碰撞对象
--------------------------------------------------------
function CrashGroup:addCrashObj(node, id, size)
    if (self.n_crashId==0) then
        self.n_crashId = id
    end
    table.insert(self.ary_obj, node)
    self.n_objCount = self.n_objCount + 1
    self.ary_carshId = G_Crash[self.n_crashId]
end



